<?php 
$Content = QContext::instance();
$base_url = $Content->requestUDI();
$search = $base_url;
$search['action'] = 'search';
$delete = $base_url;
$delete['action'] = 'del';
$sipadd = $base_url;
$sipadd['action'] = 'sipadd';

$h323add = $base_url;
$h323add['action'] = 'h323add';

$zapadd = $base_url;
$zapadd['action'] = 'zapadd';

$import = $base_url;
$import['action'] = 'import';
?>
<form id="pagerForm" method="get" action="<?php echo url($base_url,null,null,array('mode'=>'standard'));?>">
		<input type="hidden" name="pageNum" value="<?php echo $pagination['current'];?>" /> <!--【必须】value=1可以写死-->
		<input type="hidden" name="numPerPage" value="<?php echo $pagination['page_size'];?>" /> <!--【可选】每页显示多少条-->
		<input type="hidden" name="orderField" value="<?php echo $orderField;?>" />
		<input type="hidden" name="orderDirection" value="<?php echo $orderDirection;?>" />
</form>

<div class="pageHeader">
	<form rel="pagerForm" onsubmit="return navTabSearch(this);" action="<?php echo url($base_url,null,null,array('mode'=>'standard'));?>" method="get">
	<div class="searchBar">
		<ul class="searchContent">
			<li>
				<label>中继名称：</label>
				<input type="text" name="trunkname" value="<?php echo isset($param['trunkname'])?$param['trunkname']:'';?>"/>
				<input type="hidden" name="_querymethod[trunkname]" value="like">
			</li>
			<li>
				<label>状态：</label>
			<select class="combox" name="enable">
				<option value="1" <?php echo isset($param['enable'])?$param['enable']=='1'?'selected':'':'';?>>正常</option>
				<option value="0" <?php echo isset($param['enable'])?$param['enable']=='0'?'selected':'':'';?>>锁定</option>
			</select>
			</li>
		</ul>
		
		<div class="subBar">
			<ul>
				<li><div class="buttonActive"><div class="buttonContent"><button type="submit">检索</button></div></div></li>
				<li><a class="button" href="<?php echo url($search,null,null,array('mode'=>'standard'));?>" target="dialog" mask="true" title="查询框"><span>高级检索</span></a></li>
			</ul>
		</div>
	</div>
	</form>
</div>
<div class="pageContent">
	<div class="panelBar">
		<ul class="toolBar">
			
			<li><a title="确认删除此产品数据?" target="selectedTodo" rel="ids[]" href="<?php echo url($delete)?>" class="delete"><span>批量删除</span></a></li>
			<li class="line">line</li>
			<li><a class="edit" href="<?php echo url($sipadd)?>/id/{id}" target="dialog" height="500" warn="请选择一个产品"><span>修改</span></a></li>
			<li class="line">line</li>
			<li><a class="edit" href="<?php echo url($sipadd)?>/" target="navTab" rel="添加SIP中继" height="500" warn="请选择一个产品"><span>添加SIP中继</span></a></li>
			
		</ul>
	</div>
	<table class="table" width="1200" layoutH="138">
		<thead>
			<tr>
				<th width="3%"><input type="checkbox" group="ids[]" class="checkboxCtrl"></th>
				<th width="5%" orderField="acctname" >中继名</th>
				<th width="5%" >设备名称</th>
				<th width="5%" >密码</th>
				<th width="3%" orderField="enable">状态</th>
				<th width="5%" align="center" orderField="balance">并发</th>
				<th width="5%" orderField="overbalance">IP地址</th>
				<th width="5%" >协议</th>
				<th width="5%" >类型</th>
				<th width="10%" >启用</th>
				<th width="5%" >余额限制</th>
				<th width="10%" >余额</th>
				<th width="3%" >创建时间</th>
				<th width="10%" align="center">选项</th>
				
			</tr>
		</thead>
		<tbody>
		
			<?php foreach ($item as $k=>$v):?>
		
			<tr target="id" rel="<?php echo $v->id?>">
				<td><input name="ids[]" value="<?php echo $v->id?>" type="checkbox"></td>
				<td><?php echo $v->trunkname?></td>
				<td><?php 
				switch ($v->trunkprototype)
				{
					case 'dahdi':
						echo $v->username;
						break;
					default:
						echo $v->peername;
						break;	
				}
				
				?></td>
				<td><?php echo $v->secret?trim($v->secret):'空';?> </td>
				<td><?php //echo $v->peerstatetext;?></td>
				<td><?php //echo $v->curcallcount;?></td>
				<td><?php echo $v->trunkprototype == 'ip'?$v->host.':'.$v->port:$v->peeripaddr.':'.$v->peerport;?></td>
				<td><?php 
				switch ($v->trunkprototype)
				{
					case 'reg':
						echo '用户密码';
						break;
					case 'sip':
						echo 'IP对接';
						break;
					case 'iad':
						echo '语音网关';
						break;
					default:
						echo 'IP对接';
						break;	
				}
				?></td>
				<td><?php echo $v->tech;?></td>
				<td><?php echo $v->enable == 1?'开启':'关闭';?></td>
				<td><?php echo $v->balanceenable == 1?'是':'否';?></td>
				<td><?php echo $v->balance;?></td>
				<td><?php echo date('Y-m-d h:i:s',$v->createtime);?></td>
				<td>
					<a href="<?php echo url($sipadd,array('id'=>$v->id),null,array('mode'=>'standard'));?>" target="dialog" rel="page2">编辑</a>
				</td>
			</tr>
			<?php endforeach;?>
		</tbody>
	</table>
	<div class="panelBar">
			<div class="pages">
			<span>显示</span>
			<select name="numPerPage" onchange="navTabPageBreak({numPerPage:this.value})">
				<option value="20" <?php if(isset($param['numPerPage'])&&$param['numPerPage']==20)echo 'selected=selected';?>>20</option>
				<option value="50" <?php if(isset($param['numPerPage'])&&$param['numPerPage']==50)echo 'selected=selected';?>>50</option>
				<option value="100" <?php if(isset($param['numPerPage'])&&$param['numPerPage']==100)echo 'selected=selected';?>>100</option>
				<option value="200" <?php if(isset($param['numPerPage'])&&$param['numPerPage']==200)echo 'selected=selected';?>>200</option>
			</select>
				<span>共 <?php echo $pagination['record_count'];?> 条</span>
			</div>
		
		<div class="pagination" targetType="navTab" totalCount="<?php echo $pagination['record_count'];?>" numPerPage="<?php echo $pagination['page_size'];?>" pageNumShown="10" currentPage="<?php echo $pagination['current'];?>" ></div>

	</div>
</div>